<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>保存对话框</title>
	</head>
	<body>
		<button id="btn" >打开选择文件对话框</button>
		<button id="saveBtn">保存文件</button>
	</body>
	<script>
		const remote = require('electron').remote
		const fs = require('fs')
		const dialog = remote.dialog
		let openBtn = document.getElementById('btn')
		let saveBtn = document.getElementById('saveBtn')
		openBtn.onclick = function(){
			dialog.showOpenDialog({
				title:'请选择文件'
			})
		}
		saveBtn.onclick = function(){
			dialog.showSaveDialog({
				title:'请保存文件'
			}).then((result)=>{
				console.log(result)
				fs.writeFileSync(result.filePath,'文件保存在这里')
			}).catch(err=>{
				console.log(err)
			})
		}
	</script>
</html>
